package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.YonbipCashflowcase;
import com.ruoyi.system.service.IYonbipCashflowcaseService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 现金流量科目查询Controller
 * 
 * @author ruoyi
 * @date 2025-09-16
 */
@Controller
@RequestMapping("/system/cashflowcase")
public class YonbipCashflowcaseController extends BaseController
{
    private String prefix = "system/cashflowcase";

    @Autowired
    private IYonbipCashflowcaseService yonbipCashflowcaseService;

    @RequiresPermissions("system:cashflowcase:view")
    @GetMapping()
    public String cashflowcase()
    {
        return prefix + "/cashflowcase";
    }

    /**
     * 查询现金流量科目查询列表
     */
    @RequiresPermissions("system:cashflowcase:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(YonbipCashflowcase yonbipCashflowcase)
    {
        startPage();
        List<YonbipCashflowcase> list = yonbipCashflowcaseService.selectYonbipCashflowcaseList(yonbipCashflowcase);
        return getDataTable(list);
    }

    /**
     * 导出现金流量科目查询列表
     */
    @RequiresPermissions("system:cashflowcase:export")
    @Log(title = "现金流量科目查询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(YonbipCashflowcase yonbipCashflowcase)
    {
        List<YonbipCashflowcase> list = yonbipCashflowcaseService.selectYonbipCashflowcaseList(yonbipCashflowcase);
        ExcelUtil<YonbipCashflowcase> util = new ExcelUtil<YonbipCashflowcase>(YonbipCashflowcase.class);
        return util.exportExcel(list, "现金流量科目查询数据");
    }

    /**
     * 新增现金流量科目查询
     */
    @RequiresPermissions("system:cashflowcase:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存现金流量科目查询
     */
    @RequiresPermissions("system:cashflowcase:add")
    @Log(title = "现金流量科目查询", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(YonbipCashflowcase yonbipCashflowcase)
    {
        return toAjax(yonbipCashflowcaseService.insertYonbipCashflowcase(yonbipCashflowcase));
    }

    /**
     * 修改现金流量科目查询
     */
    @RequiresPermissions("system:cashflowcase:edit")
    @GetMapping("/edit/{pkDetail}")
    public String edit(@PathVariable("pkDetail") String pkDetail, ModelMap mmap)
    {
        YonbipCashflowcase yonbipCashflowcase = yonbipCashflowcaseService.selectYonbipCashflowcaseByPkDetail(pkDetail);
        mmap.put("yonbipCashflowcase", yonbipCashflowcase);
        return prefix + "/edit";
    }

    /**
     * 修改保存现金流量科目查询
     */
    @RequiresPermissions("system:cashflowcase:edit")
    @Log(title = "现金流量科目查询", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(YonbipCashflowcase yonbipCashflowcase)
    {
        return toAjax(yonbipCashflowcaseService.updateYonbipCashflowcase(yonbipCashflowcase));
    }

    /**
     * 删除现金流量科目查询
     */
    @RequiresPermissions("system:cashflowcase:remove")
    @Log(title = "现金流量科目查询", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(yonbipCashflowcaseService.deleteYonbipCashflowcaseByPkDetails(ids));
    }
}
